Skip to content

Conversation

anandsyncs
Copy link
Contributor

@anandsyncs anandsyncs commented Aug 1, 2025

Summary

This pull request introduces support for using external MongoDB deployments as sources for MongoDBSearch resources, in addition to the previously supported operator-managed deployments. The changes include updates to the CRD API, controller logic, and supporting code to handle configuration, validation, and reconciliation for external sources. Additionally, new end-to-end (e2e) test tasks are added to ensure this functionality is covered.

External MongoDB Source Support

  • Added new fields to the MongoDBSource spec (ExternalMongoDBSource and supporting types) to allow specifying external MongoDB deployments, including host/port, credentials, and TLS settings.
  • Added logic to distinguish between operator-managed and external sources throughout the controller and resource handling code, including the IsExternalMongoDBSource method and updates to resource reference logic.

Controller and Reconciliation Logic Updates

  • Refactored the SearchSourceDBResource interface and its implementations to support both internal and external MongoDB sources, including connection details and version validation.
  • Updated reconciliation logic to handle external sources, including skipping version validation and resource watching when not applicable.
  • Adjusted service and StatefulSet construction to use new abstraction for host seeds and service accounts.

Testing and CI

  • Added new e2e test tasks for external MongoDB source scenarios (e2e_search_external_basic and e2e_search_external_tls) and included them in the appropriate task groups to ensure coverage in CI.
  • Updated tests and validation helpers to use the new interface methods and logic.

These changes collectively enable MongoDBSearch resources to work with both operator-managed and external MongoDB deployments, increasing flexibility for users and improving the robustness of the operator.

Proof of Work

Tests pass

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you added changelog file?

@anandsyncs anandsyncs changed the base branch from master to search/public-preview August 1, 2025 13:30
Copy link

github-actions bot commented Aug 1, 2025

⚠️ (this preview might not be accurate if the PR is not rebased on current master branch)

MCK 1.2.1 Release Notes

Other Changes

  • Optional permissions for PersistentVolumeClaim moved to a separate role. When managing the operator with Helm it is possible to disable permissions for PersistentVolumeClaim resources by setting operator.enablePVCResize value to false (true by default). When enabled, previously these permissions were part of the primary operator role. With this change, permissions have a separate role.
  • subresourceEnabled Helm value was removed. This setting used to be true by default and made it possible to exclude subresource permissions from the operator role by specifying false as the value. We are removing this configuration option, making the operator roles always have subresource permissions. This setting was introduced as a temporary solution for this OpenShift issue. The issue has since been resolved and the setting is no longer needed.

Copy link
Contributor

@fealebenpae fealebenpae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I just recommend explicitly using distinct names for the mdbc and mdbs resources to make sure the implicit name matching isn't kicking in at all.

Please resolve the lint issue and merge.

Copy link
Contributor

@lsierant lsierant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left some comments

sample_movies_helper.assert_search_query(retry_timeout=60)


def get_connection_string(mdbc: MongoDBCommunity, user_name: str, user_password: str) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably make this an utility function as we have few copies of it already

@anandsyncs anandsyncs requested a review from lsierant August 20, 2025 10:43
@anandsyncs anandsyncs marked this pull request as ready for review August 20, 2025 11:50
@anandsyncs anandsyncs requested a review from a team as a code owner August 20, 2025 11:50
@anandsyncs anandsyncs requested review from m1kola and removed request for a team and m1kola August 20, 2025 11:50
@anandsyncs anandsyncs changed the title external mongod CLOUDP-338399: External mongod for Search Aug 20, 2025
@anandsyncs anandsyncs added the skip-changelog Use this label in Pull Request to not require new changelog entry file label Aug 20, 2025
@@ -69,7 +69,7 @@ type ExternalMongoDBSource struct {
type ExternalMongodTLS struct {
Enabled bool `json:"enabled"`
// +optional
CASecretRef *userv1.SecretKeyRef `json:"caSecretRef,omitempty"`
CA *corev1.LocalObjectReference `json:"ca,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need that object instead of just a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used this to keep it kind of consistent with rest of the codebase.

@anandsyncs anandsyncs merged commit 446c8b3 into search/public-preview Aug 26, 2025
27 of 36 checks passed
@anandsyncs anandsyncs deleted the anandsyncs/external-mongod branch August 26, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Use this label in Pull Request to not require new changelog entry file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants